import { Route, Routes, BrowserRouter } from "react-router-dom";
import { RoutesType } from "../types/routes";
import routes from "./routes";
function RouterContent() {
  const RouteComponent = (route: RoutesType[]) => {
    return route.map((item) => {
      return (
        <Route key={item.path} path={item.path} element={item.element}>
          {item?.children && RouteComponent(item.children)}
        </Route>
      );
    });
  };

  return (
    <BrowserRouter>
      <Routes>{RouteComponent(routes)}</Routes>
    </BrowserRouter>
  );
}

export default RouterContent;
